﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TodesesserMapEditor
{
    public partial class EditWall : Form
    {
        wallObject wallRef;
        public EditWall(wallObject wallReference)
        {
            InitializeComponent();
            wallRef = wallReference;
            textBox1.Text = wallReference.wall_index.ToString();
            textBox2.Text = wallReference.wall_rectangle.X.ToString();
            comboBox1.Items.Add("Wall");
            comboBox1.SelectedIndex = 0;
            textBox3.Text = wallReference.wall_rectangle.Y.ToString();
            textBox4.Text = wallReference.wall_rectangle.Width.ToString();
            textBox5.Text = wallReference.wall_rectangle.Height.ToString();
            maskedTextBox1.Text = wallReference.wall_brush.Color.R.ToString();
            maskedTextBox2.Text = wallReference.wall_brush.Color.G.ToString();
            maskedTextBox3.Text = wallReference.wall_brush.Color.B.ToString();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            setNewVars();
            this.Close();
        }

        void setNewVars()
        {
            wallRef.wall_index = int.Parse(textBox1.Text);
            wallRef.wall_rectangle.X = int.Parse(textBox2.Text);
            wallRef.wall_rectangle.Y = int.Parse(textBox3.Text);
            wallRef.wall_rectangle.Width = int.Parse(textBox4.Text);
            wallRef.wall_rectangle.Height = int.Parse(textBox5.Text);
            wallRef.wall_brush.Color = Color.FromArgb(int.Parse(maskedTextBox1.Text), int.Parse(maskedTextBox2.Text), int.Parse(maskedTextBox3.Text));
        }

        private void button1_Click(object sender, EventArgs e)
        {
            setNewVars();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            ColorDialog tempColorDialog = new ColorDialog();
            if (tempColorDialog.ShowDialog() == DialogResult.OK)
            {
                maskedTextBox1.Text = tempColorDialog.Color.R.ToString();
                maskedTextBox2.Text = tempColorDialog.Color.G.ToString();
                maskedTextBox3.Text = tempColorDialog.Color.B.ToString();
            }
        }
    }
}
